Extension point defaultRendition
Documentation
Defines the default rendition of a given document. Contributions are of the form:
<defaultRendition>
<script language="JavaScript">
function run() {
if (CurrentUser.getName() != "bob") {
return null;
}
if (!CurrentUser.getGroups().contains("members")) {
return 'aRenditionName`;
}
if (Document.getPropertyValue("dc:format") != "pdf") {
return 'pdfRendition';
}
if (Reason == "download" || doc.getType() == "Picture") {
return 'watermarkedImageRendition';
}
return 'aDefaultRendition';
</script>
</defaultRendition>
The language can be any JVM scripting language, the default is "JavaScript".
The script must define a "run()" function that returns a string which is the name of the rendition to be used. The method will get called with the following global context (some values may be null): Document (DocumentModel) CurrentUser (NuxeoPrincipal), Reason (String), Infos (Map).
Contribution Descriptors
- Class: org.nuxeo.ecm.platform.rendition.service.DefaultRenditionDescriptor
Existing Contributions
Contributions are presented in the same order as the registration order on this extension point. This order is displayed before the contribution name, in brackets.
-
<extension point="defaultRendition" target="org.nuxeo.ecm.platform.rendition.service.RenditionService"> <defaultRendition> <script language="JavaScript"> function run() { if (Reason == 'download') { if (Document.getType() == "File") { return 'mainBlob'; } else if (Document.getType() == 'Picture') { return 'mainBlob'; } else if (Document.getType() == 'Video') { return 'mainBlob'; } else if (Document.getType() == 'Audio') { return 'mainBlob'; } else if (Document.getType() == 'Note') { return 'pdf'; } else if (Document.getType() == 'Collection') { return 'containerDefaultRendition'; } else if (Document.getType() == 'Folder') { return 'containerDefaultRendition'; } else { return 'xmlExport'; } } else { return 'xmlExport'; } } </script> </defaultRendition> </extension>